<template>
  <a-modal
    :width="modalWidth"
    :style="modalStyle"
    :visible="visible"
    :maskClosable="false"
    :confirmLoading="confirmLoading"
    @ok="handleOk"
    @cancel="handleCancel"
    :keyboard="false"
    cancelText="关闭"
  >
    <template slot="title">
      <div style="width: 100%; height: 20px; padding-right: 32px">
        <div style="float: left">{{ title }}</div>
        <div style="float: right">
          <a-button
            :icon="buttonIcon"
            style="width: 56px; height: 100%; border: 0"
            @click="handleClickToggleFullScreen"
          />
        </div>
      </div>
    </template>

    <a-spin :spinning="confirmLoading">
      <a-form :form="form" layout="inline">
        <a-divider orientation="left">
          <a-button size="small" type="primary" @click="showMasterMessage = !showMasterMessage">
            {{ showMasterMessage ? '隐藏主表信息' : '显示主表信息' }}
          </a-button>
        </a-divider>
        <div v-show="showMasterMessage">
          <a-list>
            <!-- 表名、表描述、表类型 -->
            <a-list-item>
              <a-row style="width: 100%">
                <a-col :span="24">
                  <a-row :gutter="gutter" style="width: 100%">
                    <a-col :span="24 / 3">
                      <a-form-item
                        style="width: 100%"
                        :labelCol="threeCol.label"
                        :wrapperCol="threeCol.wrapper"
                        label="表名"
                      >
                        <a-input placeholder="请输入表名" v-decorator="['tableName', validatorRules.tableName]" />
                      </a-form-item>
                    </a-col>
                    <a-col :span="24 / 3">
                      <a-form-item
                        style="width: 100%"
                        :labelCol="threeCol.label"
                        :wrapperCol="threeCol.wrapper"
                        label="表描述"
                      >
                        <a-input placeholder="请输入表描述" v-decorator="['tableTxt', validatorRules.tableTxt]" />
                      </a-form-item>
                    </a-col>
                    <a-col :span="24 / 3">
                      <a-form-item
                        style="width: 100%"
                        :labelCol="threeCol.label"
                        :wrapperCol="threeCol.wrapper"
                        label="表类型"
                      >
                        <a-select @change="handleChangeInTableType" v-decorator="['tableType', { initialValue: 1 }]">
                          <a-select-option :value="1">单表</a-select-option>
                          <a-select-option :value="2">主表</a-select-option>
                          <a-select-option :value="3">附表</a-select-option>
                        </a-select>
                      </a-form-item>
                    </a-col>
                  </a-row>
                  <!-- 映射类型、附表排序序号 -->
                  <a-row :gutter="gutter" style="width: 100%" v-if="showRelationType">
                    <a-col :span="4" :push="17">
                      <a-form-item style="width: 100%" :wrapperCol="{ span: 24 }">
                        <a-radio-group v-decorator="['relationType', { initialValue: 0 }]">
                          <a-radio :value="0">一对多</a-radio>
                          <a-radio :value="1">一对一</a-radio>
                        </a-radio-group>
                      </a-form-item>
                    </a-col>
                    <a-col :span="3" :push="17">
                      <a-form-item
                        style="width: 100%"
                        :labelCol="{ span: 7 }"
                        :wrapperCol="{ span: 24 - 7 }"
                        label="序号"
                      >
                        <a-input-number
                          style="width: 100%"
                          placeholder="请输入序号"
                          v-decorator="['tabOrderNum', {}]"
                        />
                      </a-form-item>
                    </a-col>
                  </a-row>
                </a-col>
              </a-row>
            </a-list-item>
            <!-- 表单分类、主键策略、序号名称 -->
            <a-list-item>
              <a-row :gutter="gutter" style="width: 100%">
                <a-col :span="24 / 3">
                  <a-form-item
                    style="width: 100%"
                    :labelCol="threeCol.label"
                    :wrapperCol="threeCol.wrapper"
                    label="表单分类"
                  >
                    <a-select v-decorator="['formCategory', { initialValue: 'bdfl_include' }]">
                      <a-select-option value="bdfl_include">导入表单</a-select-option>
                      <a-select-option value="bdfl_ptbd">普通表单</a-select-option>
                      <a-select-option value="bdfl_fzbd">复杂表单</a-select-option>
                      <a-select-option value="bdfl_vipbd">VIP表单</a-select-option>
                    </a-select>
                  </a-form-item>
                </a-col>
                <a-col :span="24 / 3">
                  <a-form-item
                    style="width: 100%"
                    :labelCol="threeCol.label"
                    :wrapperCol="threeCol.wrapper"
                    label="主键策略"
                  >
                    <a-select v-decorator="['idType', { initialValue: 'UUID' }]" @change="handleChangeInIdType">
                      <a-select-option value="UUID">UUID(36位唯一编码)</a-select-option>
                      <a-select-option value="NATIVE">NATIVE(自增长方式)</a-select-option>
                      <a-select-option value="SEQUENCE">SEQUENCE(序列方式)</a-select-option>
                    </a-select>
                  </a-form-item>
                </a-col>
                <a-col :span="24 / 3" v-if="showIdSequence">
                  <a-form-item
                    style="width: 100%"
                    :labelCol="threeCol.label"
                    :wrapperCol="threeCol.wrapper"
                    label="序号名称"
                  >
                    <a-input placeholder="请输入序号名称" v-decorator="['idSequence', validatorRules.idSequence]" />
                  </a-form-item>
                </a-col>
              </a-row>
            </a-list-item>
            <!-- PC表单风格、移动表单风格、查询模式 -->
            <a-list-item>
              <a-row :gutter="gutter" style="width: 100%">
                <a-col :span="24 / 3">
                  <a-form-item
                    style="width: 100%"
                    :labelCol="threeCol.label"
                    :wrapperCol="threeCol.wrapper"
                    label="PC表单风格"
                  >
                    <a-select placeholder="请选择PC表单风格" v-decorator="['formTemplate', { initialValue: '1' }]">
                      <a-select-option value="1">一列</a-select-option>
                      <a-select-option value="2">两列</a-select-option>
                      <a-select-option value="3">三列</a-select-option>
                      <a-select-option value="4">四列</a-select-option>
                      <a-select-option value="99">自适应</a-select-option>
                    </a-select>
                  </a-form-item>
                </a-col>
                <!-- 暂时先隐藏 -->
                <a-col :span="24 / 3" v-if="false">
                  <a-form-item
                    style="width: 100%"
                    :labelCol="threeCol.label"
                    :wrapperCol="threeCol.wrapper"
                    label="移动表单风格"
                  >
                    <a-select placeholder="请选择移动表单风格" v-decorator="['formTemplateMobile']">
                      <a-select-option value="antdesign">AntDesign模板</a-select-option>
                      <a-select-option value="bootstrap">Bootstrap模板</a-select-option>
                    </a-select>
                  </a-form-item>
                </a-col>
                <a-col :span="24 / 3">
                  <a-form-item
                    style="width: 100%"
                    :labelCol="threeCol.label"
                    :wrapperCol="threeCol.wrapper"
                    label="查询模式"
                  >
                    <a-select v-decorator="['queryMode', { initialValue: 'single' }]">
                      <a-select-option value="single">单表查询</a-select-option>
                      <a-select-option value="group">组合查询</a-select-option>
                    </a-select>
                  </a-form-item>
                </a-col>
              </a-row>
            </a-list-item>
            <!-- 显示复选框、是否分页、是否树 -->
            <a-list-item>
              <a-row :gutter="gutter" style="width: 100%">
                <a-col :span="24 / 3">
                  <a-form-item
                    style="width: 100%"
                    :labelCol="threeCol.label"
                    :wrapperCol="threeCol.wrapper"
                    label="显示复选框"
                  >
                    <a-select v-decorator="['isCheckbox', { initialValue: 'N' }]">
                      <a-select-option value="Y">是</a-select-option>
                      <a-select-option value="N">否</a-select-option>
                    </a-select>
                  </a-form-item>
                </a-col>
                <a-col :span="24 / 3">
                  <a-form-item
                    style="width: 100%"
                    :labelCol="threeCol.label"
                    :wrapperCol="threeCol.wrapper"
                    label="是否分页"
                  >
                    <a-select v-decorator="['isPage', { initialValue: 'Y' }]">
                      <a-select-option value="Y">是</a-select-option>
                      <a-select-option value="N">否</a-select-option>
                    </a-select>
                  </a-form-item>
                </a-col>
                <a-col :span="24 / 3">
                  <a-form-item
                    style="width: 100%"
                    :labelCol="threeCol.label"
                    :wrapperCol="threeCol.wrapper"
                    label="是否树"
                  >
                    <a-select v-decorator="['isTree', { initialValue: 'N' }]" @change="handleChangeInIsTree">
                      <a-select-option value="Y">是</a-select-option>
                      <a-select-option value="N">否</a-select-option>
                    </a-select>
                  </a-form-item>
                </a-col>
              </a-row>
            </a-list-item>
            <!-- 树型表单父ID、树开表单列 -->
            <a-list-item v-if="showTreeParentIdField">
              <a-row :gutter="gutter" style="width: 100%">
                <a-col :span="24 / 3" :push="24 / 3">
                  <a-form-item
                    style="width: 100%"
                    :labelCol="threeCol.label"
                    :wrapperCol="threeCol.wrapper"
                    label="树表单父ID"
                  >
                    <a-input
                      placeholder="请输入树表单父ID"
                      v-decorator="['treeParentIdField', validatorRules.treeParentIdField]"
                    />
                  </a-form-item>
                </a-col>
                <a-col :span="24 / 3" :push="24 / 3">
                  <a-form-item
                    style="width: 100%"
                    :labelCol="threeCol.label"
                    :wrapperCol="threeCol.wrapper"
                    label="树开表单列"
                  >
                    <a-input
                      placeholder="请输入树开表单列"
                      v-decorator="['treeFieldname', validatorRules.treeFieldname]"
                    />
                  </a-form-item>
                </a-col>
              </a-row>
            </a-list-item>
            <!-- 附表 -->
            <a-list-item v-if="showSubTable">
              <a-row :gutter="gutter" style="width: 100%">
                <a-col :span="24">
                  <a-form-item style="width: 100%" :labelCol="oneCol.label" :wrapperCol="oneCol.wrapper" label="附表">
                    <a-input :disabled="true" v-decorator="['subTableStr']" />
                  </a-form-item>
                </a-col>
              </a-row>
            </a-list-item>
          </a-list>
        </div>
        <!--<a-form-item-->
        <!--:labelCol="labelCol"-->
        <!--:wrapperCol="wrapperCol"-->
        <!--label="子表">-->
        <!--<a-input placeholder="请输入子表" v-decorator="['subTableStr', {}]"/>-->
        <!--</a-form-item>-->

        <!-- - - - - - --->

        <!--/** 表ID */-->
        <!--private java.lang.String cgformHeadId;-->

        <!--/** 原字段名 */-->
        <!--private java.lang.String dbFieldNameOld;-->

        <!--/** 排序 */-->
        <!--private java.lang.Integer orderNum;-->

        <!-- - - - - - --->

        <!--<a-form-item-->
        <!--:labelCol="labelCol"-->
        <!--:wrapperCol="wrapperCol"-->
        <!--label="树表主键字段">-->
        <!--<a-input placeholder="请输入树表主键字段" v-decorator="['treeIdField', {}]"/>-->
        <!--</a-form-item>-->
      </a-form>
      <a-divider orientation="left">
        <a-button size="small" type="primary" @click="showSonMessage = !showSonMessage">
          {{ showSonMessage ? '隐藏子表信息' : '显示子表信息' }}
        </a-button>
      </a-divider>
      <div v-show="showSonMessage">
        <a-spin :spinning="tableLoading">
          <a-tabs v-model="activeKey" @change="handleChangeInTabs">
            <!-- :forceRender="true" 必须为true-->
            <a-tab-pane tab="数据库属性" key="1" :forceRender="true">
              <db-attribute-table
                ref="table1"
                @added="handleAdded"
                @deleted="handleDeleted"
                @syncDbType="handleSyncDbType"
              />
            </a-tab-pane>
            <a-tab-pane tab="页面属性" key="2" :forceRender="true">
              <page-attribute-table ref="table2" />
            </a-tab-pane>
            <a-tab-pane tab="校验字段" key="3" :forceRender="true">
              <check-dict-table ref="table3" />
            </a-tab-pane>
            <a-tab-pane tab="外键" key="4" :forceRender="true">
              <foreign-key-table ref="table4" />
            </a-tab-pane>
            <a-tab-pane tab="索引" key="5" :forceRender="true">
              <index-table ref="table5" />
            </a-tab-pane>
          </a-tabs>
        </a-spin>
      </div>
    </a-spin>
  </a-modal>
</template>

<script>
import DBAttributeTable from '../tables/DBAttributeTable'
import PageAttributeTable from '../tables/PageAttributeTable'
import CheckDictTable from '../tables/CheckDictTable'
import ForeignKeyTable from '../tables/ForeignKeyTable'
import IndexTable from '../tables/IndexTable'

import { setDataSource, getMasterTableInitialData } from '../util/TableUtils'
import { validateTables, VALIDATE_NO_PASSED } from '@/utils/JEditableTableUtil'

import { getAction, httpAction } from '@/api/manage'
import pick from 'lodash.pick'

export default {
  name: 'OnlCgformHeadModal',
  components: {
    'db-attribute-table': DBAttributeTable,
    PageAttributeTable,
    CheckDictTable,
    ForeignKeyTable,
    IndexTable,
  },
  data() {
    return {
      fullScreen: true,
      buttonIcon: 'fullscreen-exit',
      modalWidth: '100%',
      modalStyle: { top: '20px' },
      title: '操作',
      visible: false,
      activeKey: '1',
      model: {},
      gutter: 8,
      showRelationType: false,
      showTreeParentIdField: false,
      showIdSequence: false,
      showSubTable: false,
      oneCol: {
        label: { span: 2 },
        wrapper: { span: 24 - 2 },
      },
      threeCol: {
        label: { span: 6 },
        wrapper: { span: 24 - 6 },
      },
      confirmLoading: false,
      tableLoading: false,
      form: this.$form.createForm(this),
      validatorRules: {
        tableName: {
          rules: [
            {
              required: true,
              message: '请输入表名!',
            },
            {
              validator: this.validateTableName,
            },
          ],
        },
        tableTxt: { rules: [{ required: true, message: '请输入表说明!' }] },
        idSequence: { rules: [{ required: true, message: '请输入序号名称!' }] },
        treeParentIdField: { rules: [{ required: true, message: '请输入树表单父ID!' }] },
        treeFieldname: { rules: [{ required: true, message: '请输入树开表单列!' }] },
      },
      url: {
        add: '/online/cgform/head/add',
        edit: '/online/cgform/head/edit',
        addAll: '/online/cgform/api/addAll',
        editAll: '/online/cgform/api/editAll',
        queryField: '/online/cgform/field/listByHeadId',
        queryIndex: '/online/cgform/index/listByHeadId',
        checkOnlyTable: '/online/cgform/api/checkOnlyTable',
      },
      // 未验证通过
      VALIDATE_NO_PASSED: Symbol(),
      showMasterMessage: false,
      showSonMessage: true,
    }
  },
  created() {},
  mounted() {},
  methods: {
    /**
     * 获取指定的 $refs 对象
     * 有时候可能会遇到组件未挂载到页面中的情况，导致无法获取 $refs 中的某个对象
     * 这个方法可以等待挂载完成之后再返回 $refs 的对象，避免报错
     * @author sunjianlei
     **/
    getRefPromise(name) {
      let _this = this
      return new Promise((resolve) => {
        ;(function next() {
          let ref = _this.$refs[name]
          if (ref) {
            resolve(ref)
          } else {
            setTimeout(() => {
              next()
            }, 10)
          }
        })()
      })
    },

    add() {
      // 添加初始数据
      this.getAllTable().then((tables) => {
        let [table1, table2, table3, table4] = tables
        let datas = getMasterTableInitialData()
        datas.forEach((data, index) => {
          let timestamp = new Date().getTime()
          data.id = `${timestamp}${index + 1}`
        })
        // setTimeout 是为了解除添加初始化数据的时候卡住的问题，先让弹窗弹出来，再添加数据
        setTimeout(() => {
          // 先加载第一个tab的数据，可以看起来更快些
          setTimeout(() => {
            setDataSource(table2, datas)
            setDataSource(table3, datas)
            setDataSource(table4, datas)
          }, 1)
          setDataSource(table1, datas)
        }, 1)
      })

      this.edit({}, 'add')
    },
    edit(record, caller = '') {
      this.initialAllTable()
      this.activeKey = '1'
      this.visible = true
      this.toggleFullScreen(true)
      // 设置主表的数据
      this.form.resetFields()
      this.model = Object.assign({}, record)
      let pickAfter = pick(
        this.model,
        'tableName',
        'tableType',
        'tableVersion',
        'tableTxt',
        'isCheckbox',
        'isDbSynch',
        'isPage',
        'isTree',
        'idSequence',
        'idType',
        'queryMode',
        'relationType',
        'subTableStr',
        'tabOrderNum',
        'treeParentIdField',
        'treeIdField',
        'treeFieldname',
        'formCategory',
        'formTemplate',
        'formTemplateMobile'
      )
      this.initialAllShowItem(pickAfter)
      this.$nextTick(() => {
        this.form.setFieldsValue(pickAfter)
      })
      // 不是添加，就加载数据库中的数据
      if (caller !== 'add') {
        this.tableLoading = true
        Promise.all([
          getAction(this.url.queryField, { headId: this.model.id }),
          this.getRefPromise('table1'),
          this.getRefPromise('table2'),
          this.getRefPromise('table3'),
          this.getRefPromise('table4'),
        ])
          .then((results) => {
            let [{ result: fields }, table1, table2, table3, table4] = results
            table1.deleteIds = []
            table1.selectedRowKeys = []
            // 将数据同步到各表中
            setDataSource(table1, fields)
            // 延迟加载不可见的表
            setTimeout(() => {
              setDataSource(table2, fields)
              setDataSource(table3, fields)
              setDataSource(table4, fields)
            }, 100)
          })
          .catch((e) => {
            console.error(e)
          })
          .then(() => {
            this.tableLoading = false
          })
        // 加载index的数据，由于默认不可见，所以可以分开加载，提升加载效率
        Promise.all([getAction(this.url.queryIndex, { headId: this.model.id }), this.getRefPromise('table5')])
          .then((results) => {
            let [{ result: indexs }, table5] = results
            setDataSource(table5, indexs)
          })
          .catch((e) => {
            console.error(e)
          })
      }
    },
    close() {
      this.$emit('close')
      this.visible = false
      this.showMasterMessage = false
      this.showSonMessage = true
    },
    handleOk() {
      this.validateFields()
    },
    handleCancel() {
      this.close()
    },

    /** 初始化所有需要条件切换显示的项 */
    initialAllShowItem(record) {
      this.handleChangeInTableType(record.tableType || 1)
      this.handleChangeInIsTree(record.isTree || 'N')
      this.handleChangeInIdType(record.idType || 'UUID')
      this.showSubTable = (record.tableType || 1) === 2
    },

    handleChangeInTableType(value) {
      this.showRelationType = value === 3
    },
    handleChangeInIsTree(value) {
      this.showTreeParentIdField = value === 'Y'
    },
    handleChangeInIdType(value) {
      this.showIdSequence = value === 'SEQUENCE'
    },

    /* tables function */

    /** 获取所有的表 */
    getAllTable() {
      return Promise.all([
        this.getRefPromise('table1'),
        this.getRefPromise('table2'),
        this.getRefPromise('table3'),
        this.getRefPromise('table4'),
        this.getRefPromise('table5'),
      ])
    },

    /** 初始化所有的table */
    initialAllTable() {
      this.getAllTable().then((tables) => {
        tables.forEach((table) => {
          table.$refs.editableTable.initialize()
        })
      })
    },

    /** ATab切换事件 */
    handleChangeInTabs(activeKey) {
      // 当切换了选项卡的时候只同步修改当前所能看到的table
      if (['2', '3', '4', '5'].indexOf(activeKey) !== -1) {
        Promise.all([this.getRefPromise('table1'), this.getRefPromise(`table${activeKey}`)]).then((tables) => {
          let [table1, table] = tables
          table1.$refs.editableTable.resetScrollTop()
          table.syncTable(table1)
        })
      }
    },

    /** 当新增了的时候应立即同步 */
    handleAdded() {
      this.syncAllTableNow()
    },

    /** 当删除的时候也应立即同步 */
    handleDeleted() {
      this.syncAllTableNow()
    },

    /** 当value变化时同步 date */
    handleSyncDbType(event) {
      this.getRefPromise('table2').then((table2) => {
        table2.syncFieldShowType(event.row)
      })
    },

    /** 立即主动同步所有table */
    syncAllTableNow() {
      this.getAllTable().then((tables) => {
        let [table1, table2, table3, table4] = tables
        // setTimeout 是为了解除添加时的卡顿
        setTimeout(() => {
          table2.syncTable(table1)
          table3.syncTable(table1)
          table4.syncTable(table1)
        }, 50)
      })
    },

    /** 触发所有表单验证 */
    validateFields() {
      let options = {}
      new Promise((resolve, reject) => {
        // 验证主表表单
        this.form.validateFields((error, values) => {
          error ? reject(VALIDATE_NO_PASSED) : resolve({ values })
        })
      })
        .then((result) => {
          Object.assign(options, result)
          // 验证所有tables的表单
          return this.validateTableFields()
        })
        .then((values) => {
          Object.assign(options, values)
          let formData = this.classifyIntoFormData(options)
          return this.requestAddOrEdit(formData)
        })
        .catch((e) => {
          if (e.error !== VALIDATE_NO_PASSED) {
            console.error(e)
          }
        })
    },

    /** 发起请求新增或修改的请求 */
    requestAddOrEdit(formData) {
      // 判断是add还是edit
      let method = 'post',
        url = this.url.addAll
      if (this.model.id) {
        method = 'put'
        url = this.url.editAll
      }
      // 发起请求
      this.confirmLoading = true
      httpAction(url, formData, method)
        .then((res) => {
          if (res.success) {
            this.$message.success(res.message)
            this.$emit('ok')
            this.close()
          } else {
            this.$message.warning(res.message)
          }
        })
        .finally(() => {
          this.confirmLoading = false
        })
    },

    /** 将五个表的数据整理整合成后台识别的formData */
    classifyIntoFormData(options) {
      // 整理数据
      let formData = { head: {}, fields: [], indexs: [] }
      formData.head = Object.assign(this.model, options.values)

      // 整理 fields
      options.table1.values.forEach((item, index) => {
        let field = Object.assign({}, item)
        field['order_num'] = index

        let value2 = options.table2.values[index]
        field = Object.assign(value2, field)

        let value3 = options.table3.values[index]
        field = Object.assign(value3, field)

        let value4 = options.table4.values[index]
        field = Object.assign(value4, field)

        formData.fields.push(field)
      })
      formData.deleteFieldIds = options.table1.deleteIds

      // 整理 index
      formData.indexs = options.table5.values
      formData.deleteIndexIds = options.table5.deleteIds
      return formData
    },

    /** 验证并获取五个表的数据 */
    validateTableFields() {
      let _this = this
      return new Promise((resolve, reject) => {
        this.getAllTable()
          .then((tables) => {
            let cases = []
            for (let table of tables) {
              cases.push(table.$refs.editableTable)
            }
            return validateTables(cases)
          })
          .then((all) => {
            let options = {}
            all.forEach((item, index) => {
              options[`table${index + 1}`] = item
            })
            resolve(options)
          })
          .catch((e = {}) => {
            // 判断表单验证是否未通过
            if (e.error === VALIDATE_NO_PASSED) {
              // 未通过就跳转到相应的tab选项卡
              _this.activeKey = (e.index + 1).toString()
            }
            reject(e)
          })
      })
    },

    /** 切换全屏显示 */
    handleClickToggleFullScreen() {
      this.toggleFullScreen(!this.fullScreen)
    },
    /** 切换全屏显示 */
    toggleFullScreen(mode) {
      if (mode) {
        this.modalWidth = '100%'
        this.modalStyle.top = '0'
        this.modalStyle.height = '100vh'
        this.modalStyle.paddingBottom = '0'
        this.buttonIcon = 'fullscreen-exit'
      } else {
        this.modalWidth = '1200px'
        this.modalStyle.top = '50px'
        this.modalStyle.height = 'auto'
        this.modalStyle.paddingBottom = '24px'
        this.buttonIcon = 'fullscreen'
      }
      this.fullScreen = mode
    },
    validateTableName(rule, value, callback) {
      if (!value) {
        callback()
      } else {
        var patt1 = new RegExp('^[a-zA-Z]{1}_.*')
        if (patt1.test(value)) {
          callback('不能以单个字母加下划线开头')
        } else {
          var params = {
            id: !this.model.id ? '' : this.model.id,
            tbname: value,
          }
          getAction(this.url.checkOnlyTable, params).then((res) => {
            if (res.success) {
              if (res.result == -1) {
                callback('表名已存在！')
              }
            }
            callback()
          })
        }
      }
    },
  },
}
</script>

<style scoped lang="less">
</style>